package com.stu.service.impl;

import com.stu.Pojo.DePartment;
import com.stu.Pojo.Employee;
import com.stu.Pojo.Login;
import com.stu.mapper.EmployeeMapper;
import com.stu.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Service
@Transactional
public class EmployeeServiceImpl implements EmployeeService {
    @Autowired
    //注入 持久层
    private EmployeeMapper employeeMapper;

    @Override
    public List<Employee> selectALL() {
        return employeeMapper.selectALL();
    }

    @Override
    public Employee selectByid(Long id) {
        return employeeMapper.selectByid(id);
    }

    @Override
    public void insert(Employee employee) {
        employeeMapper.insert(employee);
    }

    @Override
    public void update(Employee employee) {
        employeeMapper.update(employee);
    }

    @Override
    public void delete(Long id) {
        employeeMapper.delete(id);
    }

    @Override
    public String checkPassword(Login login) {
        Employee employee = employeeMapper.selectByUserName(login.getUsername());
        if (employee==null){
            return  "请确认账号密码是否正确？";

        }
       if (employee.getPassword().equals(org.source.config.MD5Utils.string2MD5(login.getPassword()))){
           return  "密码正确";
       }
       return "非法请求";

    }
}
